﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace PhotoBook
{
    /// <summary>
    /// Interaction logic for CriarTemplate.xaml
    /// </summary>
    public partial class CriarTemplate : Window
    {
        
        private Window _JanelaAnterior;

        public CriarTemplate(Window janelaAnterior)
        {
            InitializeComponent();
            _JanelaAnterior = janelaAnterior;
        }
              

        private void CriarTemplate_Closed(object sender, System.EventArgs e)
        {
            _JanelaAnterior.Show();            
        }

        private void DragMouse(object sender, MouseButtonEventArgs e)
        {
            Image image = e.Source as Image;
            DataObject data = new DataObject(typeof(ImageSource), image.Source);
            DragDrop.DoDragDrop(image, data, DragDropEffects.Copy);            
        }

        private void Canvas_DragEnter(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(typeof(Image)))
            {                
                e.Effects = DragDropEffects.Copy;   
            }            
        }

        private void Canvas_Drop(object sender, DragEventArgs e)
        {
            ImageSource image = e.Data.GetData(typeof(ImageSource)) as ImageSource;
            Image imageControl = new Image() { Width = image.Width, Height = image.Height, Source = image, Stretch=Stretch.Uniform};
            Canvas.SetLeft(imageControl, e.GetPosition(this.CanvasCentro).X);
            Canvas.SetTop(imageControl, e.GetPosition(this.CanvasCentro).Y);
            this.CanvasCentro.Children.Add(imageControl);           
        }

        private void Button1_Click(object sender, RoutedEventArgs e)
        {
            
        }

    }
}
